<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="description" content="LAMP环境搭建"/>
    <meta name="keywords"
          content="nginx,freebsd,linux,mysql,shell,apache,centos,redhat,rhel,windows,sql,系统运维,IT运维,开源系统,开源系统运维"/>
    <title> LAMP环境搭建 </title>

</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="menu">
    <ul>
		<span style="FONT-SIZE: 10.5pt">

			<li><a href="index.htm" hidefocus="true" id="mn_list">linux入门教程</a></li>

		</span>
    </ul>
</div>
<p style="TEXT-ALIGN: center"><span style="FONT-SIZE: 15pt; FONT-FAMILY: '宋体'"><b>第十六章</b></span><span
        style="FONT-SIZE: 15pt;"><b> LAMP</b></span><span style="FONT-SIZE: 15pt; FONT-FAMILY: '宋体'"><b>环境搭建</b></span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;"></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">经过前部分章节的学习，你已经掌握了</span><span
        style="FONT-SIZE: 10.5pt;">linux</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">的基础知识了</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">但是想成为一名系统管理员恐怕还有点难度，因为好多单位招聘这个职位的时候都要求有一定的工作经验</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">然而真正的经验一天两天是学不来的，是靠长时间积累得来的</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">不过你也不要灰心，所谓的工作经验无非也就是一些运行在</span><span style="FONT-SIZE: 10.5pt;">linux</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">系统上的软件的配置以及应用</span><span style="FONT-SIZE: 10.5pt;">。</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">就好像是装在</span><span style="FONT-SIZE: 10.5pt;">windows</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">上的</span><span style="FONT-SIZE: 10.5pt;">office</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">一样，大部分人都会装，但是十分会用的却不多</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">是因为</span><span
        style="FONT-SIZE: 10.5pt;">office</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">太难吗，当然不是，只是因为只有一小部分人花费了很长很长的时间去使用和研究</span><span
        style="FONT-SIZE: 10.5pt;">office</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">而已</span><span
        style="FONT-SIZE: 10.5pt;">。</span></p>


<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">LAMP </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">是</span><span
        style="FONT-SIZE: 10.5pt;">Linux Apache MySQL PHP</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">的简写，其实就是把</span><span
        style="FONT-SIZE: 10.5pt;">Apache, MySQL</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">以及</span><span
        style="FONT-SIZE: 10.5pt;">PHP</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">安装在</span><span
        style="FONT-SIZE: 10.5pt;">Linux</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">系统上，组成一个环境来运行</span><span
        style="FONT-SIZE: 10.5pt;">php</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">的脚本语言</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">至于什么是</span><span
        style="FONT-SIZE: 10.5pt;">php</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">脚本语言，笔者不再介绍，请自己查资料吧</span><span
        style="FONT-SIZE: 10.5pt;">。Apache</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">是最常用的</span><span
        style="FONT-SIZE: 10.5pt;">WEB</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">服务软件，而</span><span
        style="FONT-SIZE: 10.5pt;">MySQL</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">是比较小型的数据库软件，这两个软件以及</span><span
        style="FONT-SIZE: 10.5pt;">PHP</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">都可以安装到</span><span
        style="FONT-SIZE: 10.5pt;">windows</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">的机器上</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">下面笔者就教你如何构建这个</span><span
        style="FONT-SIZE: 10.5pt;">LAMP</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">环境</span><span
        style="FONT-SIZE: 10.5pt;">。</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">【</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>安装</b></span><span
        style="FONT-SIZE: 10.5pt;"><b>MySQL</b></span><span style="FONT-SIZE: 10.5pt;">】</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;"></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">一般我们平时安装</span><span style="FONT-SIZE: 10.5pt;">MySQL</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">都是</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">源码</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">包安装的，但是由于它的</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">编译</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">需要很长的</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">时间</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">，所以，笔者建议你安装二进制免编译包</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">你可以到</span><span
        style="FONT-SIZE: 10.5pt;">MySQL</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">官方网站去</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">下载:</span><span style="FONT-SIZE: 10.5pt;"><a
        href="javascript:if(confirm('http://www.mysql.com/downloads/  \n\n���ļ��޷��� Teleport Ultra ����, ��Ϊ ����һ�����·���ⲿ������Ϊ������ʼ��ַ�ĵ�ַ��  \n\n�����ڷ������ϴ���?'))window.location='http://www.mysql.com/downloads/'">下面是安装步骤：</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">1. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">下载</span><span style="FONT-SIZE: 10.5pt;">mysql</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">到</span><span style="FONT-SIZE: 10.5pt;">/usr/local/src/ </span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">cd /usr/local/src/</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">wget&nbsp; http://syslab.comsenz.com/downloads/linux/mysql-5.0.86-linux-i686-icc-glibc23.tar.gz</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;"></span><span style="FONT-SIZE: 10.5pt;">2. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">解压</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">tar zxvf /usr/local/src/mysql-5.0.86-linux-i686-icc-glibc23.tar.gz</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">3. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">把解压完的</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">数据</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">移动到</span><span style="FONT-SIZE: 10.5pt;">/usr/local/mysql</span>
</p>
<p style="TEXT-ALIGN: justify"><span
        style="FONT-SIZE: 10.5pt;">mv mysql-5.0.86-linux-i686-icc-glibc23 /usr/local/mysql</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">4. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">建立</span><span style="FONT-SIZE: 10.5pt;">mysql</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">用户</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">useradd mysql</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">5. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">初始化数据库</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">cd /usr/local/mysql</span></p>
<p style="TEXT-ALIGN: justify"><span
        style="FONT-SIZE: 10.5pt;">mkdir /data/mysql ; chown -R mysql:mysql /data/mysql</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">./scripts/mysql_install_db --user=mysql --datadir=/data/mysql </span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">--user</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">定义数据库的所属主，</span><span
        style="FONT-SIZE: 10.5pt;">--datadir</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">定义数据库安装到哪里，建议放到大空间的分区上，这个目录需要自行创建</span><span
        style="FONT-SIZE: 10.5pt;">。</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">6. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">拷贝配置文件</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">cp support-files/my-large.cnf /etc/my.cnf</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">7. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">拷贝启动脚本文件并修改其属性</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">cp support-files/mysql.server&nbsp;&nbsp;/etc/init.d/mysqld</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">chmod 755 /etc/init.d/mysqld</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">8. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">修改启动脚本</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">vim /etc/init.d/mysqld</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">需要修改的地方有</span><span
        style="FONT-SIZE: 10.5pt;">datadir=/data/mysql</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">（前面初始化数据库时定义的目录）</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">9. </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">把启动脚本加入系统服务项，并设定开机启动，启动</span><span style="FONT-SIZE: 10.5pt;">mysql</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">chkconfig --add mysqld</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">chkconfig mysqld on</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">service mysqld start</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">如果启动不了，请到</span><span
        style="FONT-SIZE: 10.5pt;">/data/mysql/ </span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">下查看错误日志，这个日志通常是主机名.err</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">关于</span><span
        style="FONT-SIZE: 10.5pt;">mysql</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">的配置文件</span><span
        style="FONT-SIZE: 10.5pt;">/etc/my.cnf</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">请参考这篇文章</span><span style="FONT-SIZE: 10.5pt;"> </span><span
        style="FONT-SIZE: 10.5pt;"><a
        href="javascript:if(confirm('http://www.92csz.com/19/603.html  \n\n���ļ��޷��� Teleport Ultra ����, ��Ϊ ����һ�����·���ⲿ������Ϊ������ʼ��ַ�ĵ�ַ��  \n\n�����ڷ������ϴ���?'))window.location='http://www.92csz.com/19/603.html'">http://www.92csz.com/19/603.html</a></span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">【</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>安装</b></span><span
        style="FONT-SIZE: 10.5pt;"><b>Apache</b></span><span style="FONT-SIZE: 10.5pt;">】</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">cd /usr/local/src/</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">wget&nbsp; http://syslab.comsenz.com/downloads/linux/httpd-2.2.11.tar.gz</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;"></span><span
        style="FONT-SIZE: 10.5pt;">useradd www </span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">（增加</span><span
        style="FONT-SIZE: 10.5pt;"> Apache</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">运行账户）</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">tar zvxf httpd-2.2.11.tar.bz2</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">cd httpd-2.2.11</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">./</span><span
        style="FONT-SIZE: 10.5pt;">conf</span><span style="FONT-SIZE: 10.5pt;">igure
 --prefix=/usr/local/apache2 --with-included-apr --enable-so 
--enable-deflate=shared --enable-expires=shared --enable-rewrite=shared 
--enable-static-support --disable-userdir</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">make</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">make </span><span
        style="FONT-SIZE: 10.5pt;">install</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;"></span>&nbsp;</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">【</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>安装</b></span><span
        style="FONT-SIZE: 10.5pt;"><b>PHP</b></span><span style="FONT-SIZE: 10.5pt;">】</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">wget http://syslab.comsenz.com/downloads/linux/php-5.2.10.tar.gz</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">tar zvxf </span><span
        style="FONT-SIZE: 10.5pt;">php</span><span
        style="FONT-SIZE: 10.5pt;">-5.2.10.tar.gz<br>cd php-5.2.10<br>./</span><span
        style="FONT-SIZE: 10.5pt;">conf</span><span style="FONT-SIZE: 10.5pt;">igure --prefix=/usr/local/php \ <br>--with-apxs2=/usr/local/apache2/bin/apxs \<br>--with-config-file-path=/usr/local/php/etc \<br>--with-mysql=/usr/local/mysql \<br>--with-libxml-dir \<br>--with-gd \<br>--with-jpeg-dir \<br>--with-png-dir \<br>--with-freetype-dir \<br>--with-iconv-dir \<br>--with-zlib-dir&nbsp;&nbsp;\<br>--with-bz2 \<br>--with-openssl \<br>--with-mcrypt \<br>--enable-soap \<br>--enable-gd-native-ttf \<br>--enable-ftp \<br>--enable-mbstring \<br>--enable-sockets \<br>--enable-exif \<br>--disable-ipv6 <br>make &amp;&amp; make install<br>mkdir /usr/local/php/etc<br>cp php.ini-dist /usr/local/php/etc/php.ini</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">【</span><span
        style="FONT-SIZE: 10.5pt;"><b>apache</b></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>结合</b></span><span
        style="FONT-SIZE: 10.5pt;"><b>php</b></span><span style="FONT-SIZE: 10.5pt;">】</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">Apache</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">主配置</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">文件</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">为：</span><span
        style="FONT-SIZE: 10.5pt;">/usr/local/apache2/</span><span style="FONT-SIZE: 10.5pt;">conf</span><span
        style="FONT-SIZE: 10.5pt;">/httpd.conf<br># vim /usr/local/apache2/conf/httpd.conf<br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">找到：</span><span style="FONT-SIZE: 10.5pt;"><br>AddType application/x-gzip .gz .tgz<br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">在该行下面添加</span><span style="FONT-SIZE: 10.5pt;"><br>AddType application/x-httpd-</span><span
        style="FONT-SIZE: 10.5pt;">php</span><span style="FONT-SIZE: 10.5pt;"> .php<br><br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">找到：</span><span style="FONT-SIZE: 10.5pt;"><br>&lt;IfModule dir_module&gt;<br>&nbsp; &nbsp; DirectoryIndex index.html<br>&lt;/IfModule&gt;<br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">将该行改为</span><span style="FONT-SIZE: 10.5pt;"><br>&lt;IfModule dir_module&gt;<br>&nbsp; &nbsp; DirectoryIndex index.html index.htm index.php<br>&lt;/IfModule&gt;<br><br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">找到：</span><span style="FONT-SIZE: 10.5pt;"><br>#Include conf/extra/httpd-mpm.conf<br>#Include conf/extra/httpd-info.conf<br>#Include conf/extra/httpd-vhosts.conf<br>#Include conf/extra/httpd-default.conf<br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">去掉前面的</span><span style="FONT-SIZE: 10.5pt;">“#”</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">号，取消注释</span><span style="FONT-SIZE: 10.5pt;">。</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">【</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>配置</b></span><span
        style="FONT-SIZE: 10.5pt;"><b>apache</b></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>的进程管理以及虚拟主机</b></span><span style="FONT-SIZE: 10.5pt;">】</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;"><b>1. </b></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>配置</b></span><span
        style="FONT-SIZE: 10.5pt;"><b>Apache</b></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>进程管理</b></span><span style="FONT-SIZE: 10.5pt;"><br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">配置文件为：</span><span style="FONT-SIZE: 10.5pt;">/usr/local/apache2/conf/extra/httpd-mpm.conf<br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">将配置文件中下面一段修改为如下：</span><span style="FONT-SIZE: 10.5pt;"><br>&lt;IfModule mpm_prefork_module&gt;<br>&nbsp; &nbsp; ServerLimit&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 2048&nbsp; &nbsp; </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">新添加</span><span style="FONT-SIZE: 10.5pt;"><br>&nbsp; &nbsp; StartServers&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 5<br>&nbsp; &nbsp; MinSpareServers&nbsp; &nbsp;&nbsp; &nbsp;5<br>&nbsp; &nbsp; MaxSpareServers&nbsp; &nbsp;&nbsp; &nbsp;10<br>&nbsp; &nbsp; MaxClients&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;1024 </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">默认最大为</span><span style="FONT-SIZE: 10.5pt;">256</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">，设置为超过</span><span style="FONT-SIZE: 10.5pt;">256</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">必须增加有</span><span style="FONT-SIZE: 10.5pt;">ServerLimit<br>&nbsp; &nbsp; MaxRequestsPerChild&nbsp; &nbsp;0<br>&lt;/IfModule&gt;</span>
</p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;"><b>2. </b></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>配置</b></span><span
        style="FONT-SIZE: 10.5pt;"><b>Apache</b></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>虚拟主机</b></span><span style="FONT-SIZE: 10.5pt;"><br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">配置文件为：</span><span style="FONT-SIZE: 10.5pt;">/usr/local/apache2/conf/extra/httpd-vhosts.conf<br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">将配置文件中下面一段修改为如下：</span><span style="FONT-SIZE: 10.5pt;"><br>&lt;VirtualHost *:80&gt;<br>&nbsp; &nbsp;# ServerAdmin </span><span
        style="FONT-SIZE: 10.5pt;">webmaster@dummy-host.example.com</span><span style="FONT-SIZE: 10.5pt;"><br>&nbsp; &nbsp; DocumentRoot "/data/www"<br>&nbsp; &nbsp; ServerName </span><span
        style="FONT-SIZE: 10.5pt;">www.example.com.cn</span><span style="FONT-SIZE: 10.5pt;"><br>&nbsp; &nbsp; ErrorLog "|/usr/local/apache2/bin/rotatelogs -l /www/logs/error.log-%Y%m%d 86400"<br>&nbsp; &nbsp;CustomLog "|/usr/local/apache2/bin/rotatelogs -l /www/logs/access.log-%Y%m%d 86400" combined<br>&nbsp; &nbsp;&lt;/VirtualHost&gt;<br><br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">说明：</span><span
        style="FONT-SIZE: 10.5pt;"><br>ServerAdmin </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">参数后为管理员</span><span style="FONT-SIZE: 10.5pt;">email<br>DocumentRoot </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">指的是论坛文件存放的目录</span><span style="FONT-SIZE: 10.5pt;"><br>ServerName&nbsp;&nbsp;</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">是论坛的域名</span><span
        style="FONT-SIZE: 10.5pt;"><br>ErrorLog </span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">是论坛错误日志</span><span
        style="FONT-SIZE: 10.5pt;">&nbsp;&nbsp;</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">通过管道使用</span><span style="FONT-SIZE: 10.5pt;">apache</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">自带的</span><span style="FONT-SIZE: 10.5pt;">rotatelogs</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">工具将日志切割为每天一个文件</span><span style="FONT-SIZE: 10.5pt;"><br>CustomLog </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">是论坛访问日志，同样切割为每天一个文件</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">配置</span><span
        style="FONT-SIZE: 10.5pt;">Apache</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">缺省</span><span
        style="FONT-SIZE: 10.5pt;">httpd</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">设置</span><span
        style="FONT-SIZE: 10.5pt;"><br></span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">配置文件为：</span><span
        style="FONT-SIZE: 10.5pt;">/usr/local/apache2/conf/extra/httpd-default.conf<br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">将配置文件中下面一段：</span><span style="FONT-SIZE: 10.5pt;"><br></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">将</span><span style="FONT-SIZE: 10.5pt;">KeepAlive On </span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">改为</span><span style="FONT-SIZE: 10.5pt;">KeepAlive Off<br>
  <table cellpadding="0" cellspacing="0">
    <tbody><tr>
      <td class="t_msgfont" id="postmessage_1006">
<p>配置Apache的访问权限<br>vim /usr/local/apache2/conf/httpd.conf<br>找到<br>&lt;Directory /&gt;<br>Options FollowSymlinks<br>AllowOverride
    None<br>Order deny,allow<br>Deny form all<br>&lt;/Directory&gt;<br>改成：<br>&lt;Directory /&gt;<br>Options
    FollowSymlinks<br>AllowOverride None<br>Order deny,allow<br>Allow form all<br>&lt;/Directory&gt;
    <!--++ plugin_code qcomic begin--><br>
    <!--++ plugin_code qcomic end-->配置Apache的运行账户<br>vim&nbsp; /usr/local/apache2/conf/httpd.conf<br>找到<br>User&nbsp;
    daemon<br>Group daemon<br>改成<br>User www<br>Group www</p></td>
</tr>
</tbody></table>
</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">配置完上述内容之后，启动</span><span
        style="FONT-SIZE: 10.5pt;">Apache</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">：</span><span
        style="FONT-SIZE: 10.5pt;"><br>/usr/local/apache2/bin/apachectl start</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">【</span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>测试</b></span><span style="FONT-SIZE: 10.5pt;"><b>LAMP</b></span><span
        style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>是否成功</b></span><span style="FONT-SIZE: 10.5pt;">】</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">vim /data/www/1.php</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">写入：</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">&lt;?php <br></span><span style="FONT-SIZE: 10.5pt;">phpinfo();<br></span><span
        style="FONT-SIZE: 10.5pt;">?&gt;</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">保存后，然后在浏览器中输入</span><span
        style="FONT-SIZE: 10.5pt;"> http://</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">你配置的域名</span><span
        style="FONT-SIZE: 10.5pt;">/1.php </span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">看是否能看到</span><span
        style="FONT-SIZE: 10.5pt;">php</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">的相关配置信息</span><span
        style="FONT-SIZE: 10.5pt;">。</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">【</span><span
        style="FONT-SIZE: 10.5pt;"><b>Zend</b></span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"><b>安装</b></span><span
        style="FONT-SIZE: 10.5pt;">】</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">有时，需要在你的</span><span
        style="FONT-SIZE: 10.5pt;">LAMP</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">环境中配置</span><span
        style="FONT-SIZE: 10.5pt;">ZEND</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">，因为有些</span><span
        style="FONT-SIZE: 10.5pt;">php</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">的应用程序比如</span><span
        style="FONT-SIZE: 10.5pt;">Discuz! </span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">或者</span><span
        style="FONT-SIZE: 10.5pt;">phpwind</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">等是需要用</span><span
        style="FONT-SIZE: 10.5pt;">zend</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">来解密的，不装</span><span
        style="FONT-SIZE: 10.5pt;">zend</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">会显示乱码</span><span
        style="FONT-SIZE: 10.5pt;">。</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">安装步骤为：</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">cd /usr/local/src</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">wget http://syslab.comsenz.com/downloads/linux/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz</span>
</p>
<p style="TEXT-ALIGN: justify"><span
        style="FONT-SIZE: 10.5pt;">tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz</span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">cd ZendOptimizer-3.3.3-linux-glibc23-i386 </span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">./install.sh </span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">根据提示安装</span><span
        style="FONT-SIZE: 10.5pt;">。php.ini文件的路径为：/usr/local/php/etc/ 当提示是否重启apache时，选择不重启。</span></p>

<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'">上一页 <a
        href="15.htm">linux系统日常管理</a></span></p>
<p style="TEXT-ALIGN: justify"><span style="FONT-SIZE: 10.5pt;">下一页 <a href="17.htm">LNMP环境搭建</a><a></a></span></p><a>
</a>
<p style="TEXT-ALIGN: justify"><a><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: '宋体'"></span></a><a href="index.htm">回到主目录</a>&nbsp;
</p>

</body>
</html>